#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

const int N = 35;

typedef pair<int, int> PII;

int x, y;
char a[N][N];
int dist[N][N];
int n, m;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};


void bfs()
{
	memset(dist, -1, sizeof dist);
	queue<PII> q;
	q.push({x, y});
	dist[x][y] = 0;
	while(q.size())
	{
		auto t = q.front(); q.pop();
		int i = t.first, j = t.second;
		for(int k = 0; k < 4; k++)
		{
			int x = i + dx[k];
			int y = j + dy[k];
			if(x >= 1 && y >= 1 && x <= n && y <= m && dist[x][y] == -1 && a[x][y] != '*')
			{
				dist[x][y] = dist[i][j] + 1;
				if(a[x][y] == 'e') continue;
				q.push({x, y});
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			cin >> a[i][j];
			if(a[i][j] == 'k')
			{
				x = i;
				y = j;
//				cout << x << y << endl;
			}
		}
	}
	
	bfs();
	
	int ret = 0;
	int path = 1e9;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(a[i][j] == 'e' && dist[i][j] != -1) 
			{
				ret++;
				path = min(path, dist[i][j]);
			}
		}
	}
	
	if(ret == 0) cout << -1 << endl;
	else cout << ret << " " << path << endl;
	
	return 0;
}
